using UnityEngine;

public class ImproveVCData
{
    public string name;
}

public class ImproveViewController : ViewController
{
    private MBattleSceneController battleSceneController => GetComponentInParent<MBattleSceneController>();
    MBattleController battleScene => battleSceneController .mBattleController;

    ImprovePanel m_Panel;
    public ImprovePanel panel => m_Panel;

    ImproveVCData m_Data;

    public ImprovePanel Init(ImproveVCData data)
    {
        if (m_Panel == null)
            m_Panel = InitUI();

        GameDebug.LogError($"data != null:{data != null}");

        m_Data = data;
        m_Panel.Init(data);

        return m_Panel;
    }

    protected override void WillLoadView()
    {
        base.WillLoadView();
    }

    protected ImprovePanel InitUI()
    {
        ImprovePanel prefab = ResourceManager.Load<ImprovePanel>(ViewPath.improvePanel);
        if (prefab == null)
        {
            GameDebug.LogError("HomePanel prefab null");
            return null;
        }
        m_Panel = GameObject.Instantiate<ImprovePanel>(prefab, transform);
        m_Panel.SetViewController(this);
        // panel.name = "战斗UI";
        return m_Panel;
    }

    public override void WillHideView()
    {
        base.WillHideView();

        if (m_Panel)
        {
            m_Panel.PlayHideAnim();
        }
    }


    public override void OnViewDelete()
    {
        base.OnViewDelete();

        if (m_Panel)
        {
            Destroy(m_Panel.gameObject);
        }
        m_Panel = null;
    }

    public static ImproveVCData GetImproveVCData(MGameUser gameUser)
    {
        ImproveVCData homeVcData = new ImproveVCData();

        homeVcData.name = gameUser.name;
        
        return homeVcData;
    }
}